// pages/pullPeople/pullPeople.js
const app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    text:'搜索',
    name: '',
    memberList: []
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.searchMember()
  },
  pullMember(e) {
    let memberId = e.currentTarget.dataset['member']
    wx.request({
      url: app.globalData.prefix + "/corpsAction/pullMember.do",
      data: {
        openId: app.globalData.userInfo.openId,
        memberId: memberId
      },
      method: 'POST',
      success: (res) => {
        let status = res.data.status
        if (status == "00") {
          wx.$showToast(res.data.result)
          this.searchMember()
        } else {
          wx.$showToast(res.data.errorMsg)
        }
      }
    })
  },
  nameInput(e) {
    this.setData({
      name: e.detail.value
    })
  },
  searchMember(){
    wx.request({
      url: app.globalData.prefix + "/corpsAction/noCorpsMember.do",
      data: {
        name:this.data.name
      },
      success: (res) => {
        let status = res.data.status
        if (status == "00") {
          let data = res.data.result
          this.setData({
            memberList: data
          })
        } else {
          wx.$showToast(res.data.errorMsg)
        }
      }
    })
  }
})